package com.google.code.irouter.portal.client.dashboard.main.center.managers.relation.browser.monitor;

import com.google.code.irouter.portal.client.AppConstants;
import com.google.gwt.core.client.GWT;
import com.gwtext.client.data.ArrayReader;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.FloatFieldDef;
import com.gwtext.client.data.MemoryProxy;
import com.gwtext.client.data.RecordDef;
import com.gwtext.client.data.Store;
import com.gwtext.client.data.StringFieldDef;
import com.gwtext.client.widgets.chart.yui.LineChart;
import com.gwtext.client.widgets.chart.yui.NumericAxis;
import com.gwtext.client.widgets.chart.yui.SeriesDefY;

public final class Trend extends LineChart {
	
	private static final AppConstants CONSTANTS = GWT.create(AppConstants.class);
	
	public Trend() {
		super();
		this.setId(Trend.class.getName());
		
		this.setTitle(CONSTANTS.com_google_code_irouter_portal_client_dashboard_main_center_managers_relation_browser_monitor_trend_title());
		//-----------------------------------------
		MemoryProxy proxy = new MemoryProxy(getData());  
        RecordDef recordDef = new RecordDef(  
                new FieldDef[]{  
                        new StringFieldDef("month"),  
                        new FloatFieldDef("rent"),  
                        new FloatFieldDef("utilities")  
                }  
        );  
  
        ArrayReader reader = new ArrayReader(recordDef);  
        final Store store = new Store(proxy, reader);  
        store.load();  
  
        SeriesDefY[] seriesDef = new SeriesDefY[]{  
  
                new SeriesDefY("Rent", "rent"),  
                new SeriesDefY("Utilities", "utilities")  
  
        };  
  
        NumericAxis currencyAxis = new NumericAxis();  
        currencyAxis.setMinimum(800);  
		//-----------------------------------------
		
		this.setWMode("transparent");  
		this.setStore(store);  
		this.setSeries(seriesDef);  
		this.setXField("month");  
        this.setYAxis(currencyAxis);  
        this.setDataTipFunction("getDataTipText");  
        this.setExpressInstall("js/yui/assets/expressinstall.swf");
        this.setHeight(200);
	}
	
	private static Object[][] getData() {  
        return new Object[][]{  
                new Object[]{"January", new Double(880.00), new Double(894.68)},  
                new Object[]{"February", new Double(880.00), new Double(901.35)},  
                new Object[]{"March", new Double(880.00), new Double(889.32)},  
                new Object[]{"April", new Double(880.00), new Double(884.71)},  
                new Object[]{"May", new Double(910.00), new Double(879.811)},  
                new Object[]{"June", new Double(910.00), new Double(897.95)}  
        };  
    }  

}
